package com.suzhenyu.jmh;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import java.util.ArrayList;
import java.util.Stack;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author suzy2
 */
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS)
@Threads(2)
@Fork(2)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class JmhTest {
    private AtomicInteger i = new AtomicInteger(0);
    private int a =0;
    @Benchmark
    public void wellHelloThere(){
            a ++;
         i.incrementAndGet();
            if(a != i.intValue()){
//                System.out.println(a+":"+i.intValue());
                a =i.intValue();
                Stack st = new Stack();
                st.push(1);
                st.pop();
            }

    }


    public static void main(String[] args) throws RunnerException {

        System.out.println(Math.round(-1.5));

    }
}
